package com.leihao.product.service.impl;

import com.leihao.product.domian.MemberPrice;
import com.leihao.product.mapper.MemberPriceMapper;
import com.leihao.product.service.MemberPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class MemberPriceServiceImpl implements MemberPriceService {
    @Autowired
    private MemberPriceMapper memberPriceMapper;
    @Override
    public void addBatch(List<MemberPrice> list) {
        if (CollectionUtils.isEmpty(list)){
            throw new RuntimeException("集合不能为空!");
        }
        memberPriceMapper.addBatch(list);
    }

    @Override
    public void update(MemberPrice memberPrice) {
        if (memberPrice == null){
            throw new RuntimeException("参数不能为空!");
        }
        if (memberPrice.getMemberPriceId() == null){
            throw new RuntimeException("主键不能为空!");
        }
        memberPriceMapper.update(memberPrice);
    }

    @Override
    public void deleteMemberPriceList(Integer productId) {
        if (productId == null){
            throw new RuntimeException("参数不能为空!");
        }
        memberPriceMapper.deleteMemberPriceList(productId);
    }
}
